def main():
    year=int(input())
    month=int(input())
    day=int(input())
    aws=0
    pre_month=month-1
    if (year%4==0 and year%100!=0)or(year%400==0):
         while pre_month>0:
            if pre_month in (1,3,5,7,8,10,12):
                aws+=31
                pre_month-=1
            elif pre_month==2:
                aws+=29
                pre_month-=1
            else:
                aws+=30
                pre_month-=1
    else:
        while pre_month>0:
            if pre_month in (1,3,5,7,8,10,12):
                aws+=31
                pre_month-=1
            elif pre_month==2:
                aws+=28
                pre_month-=1
            else:
                aws+=30
                pre_month-=1
    print(aws+day)
main()